home *** CD-ROM | disk | FTP | other *** search
/ The Sunday Times: The Month 2004 August / The Sunday Times - The Month 2004-08.iso / pc / engine / modules / calculator.swf / scripts / frame_1 / DoAction.as
Encoding:
Text File  |  2004-06-24  |  2.6 KB  |  58 lines

  1. function init()
  2. {
  3.    var _loc2_ = Tardis.ActiveSection.id;
  4.    var _loc1_ = Tardis.Colors;
  5.    strSECTION_COLOR = _loc1_.getString(_loc2_);
  6.    SECTION_COLOR = _loc1_.getHex(_loc2_);
  7.    strSECTION_COLOR50 = _loc1_.getString(_loc2_ + "50");
  8.    SECTION_COLOR50 = _loc1_.getHex(_loc2_ + "50");
  9.    DEFAULT_COLOR = _loc1_.getHex("default");
  10.    DEFAULT_COLOR50 = _loc1_.getString("default50");
  11.    strDEFAULT_COLOR = _loc1_.getString("default");
  12.    cost = nodeData.byName("cost").getText();
  13.    onComplete();
  14.    var strTitle = "<FONT COLOR=\"" + strSECTION_COLOR + "\">" + nodeData.byName("labels").byName("title").getText() + "</FONT> ";
  15.    title_FF.htmlText = strTitle;
  16.    var strIntro = "<FONT COLOR=\"" + strDEFAULT_COLOR + "\">" + nodeData.byName("labels").byName("intro").getText() + "</FONT> ";
  17.    intro_FF.htmlText = strIntro;
  18.    currency_1.htmlText = currency_2.htmlText = nodeData.byName("labels").byName("currency").getText();
  19.    var _loc3_ = "<FONT COLOR=\"" + strDEFAULT_COLOR + "\">" + nodeData.byName("labels").byName("byline1").getText() + "</FONT> ";
  20.    byline_1.htmlText = _loc3_;
  21.    var strByline2 = "<FONT COLOR=\"" + strDEFAULT_COLOR + "\">" + nodeData.byName("labels").byName("byline2").getText() + "</FONT> ";
  22.    byline_2.htmlText = strByline2;
  23.    calculate.txt.htmlText = nodeData.byName("labels").byName("calculate").getText();
  24.    calculate.txt.autoSize = "left";
  25.    calculate.arrowMC._x = calculate.txt._width + 4;
  26. }
  27. stop();
  28. onReady();
  29. var cost;
  30. calculate.onPress = function()
  31. {
  32.    var _loc1_ = Math.ceil(cost / Number(income_txt.text));
  33.    if(_loc1_ == Infinity || isNaN(_loc1_) || _loc1_ < 1)
  34.    {
  35.       var _loc3_ = "<FONT COLOR=\"" + strSECTION_COLOR + "\">" + nodeData.byName("labels").byName("result1").getText() + "</FONT> ";
  36.       output1.htmlText = _loc3_;
  37.    }
  38.    else if(_loc1_ > 104)
  39.    {
  40.       _loc3_ = "<FONT COLOR=\"" + strSECTION_COLOR + "\">" + nodeData.byName("labels").byName("result2").getText() + "</FONT> ";
  41.       output1.htmlText = _loc3_;
  42.    }
  43.    else if(_loc1_ > 1)
  44.    {
  45.       var _loc2_ = nodeData.byName("labels").byName("result4").getText().split("|");
  46.       _loc3_ = "<FONT COLOR=\"" + strSECTION_COLOR + "\">" + _loc2_[0] + " " + _loc1_ + " " + _loc2_[1] + "</FONT> ";
  47.       output1.htmlText = _loc3_;
  48.    }
  49.    else
  50.    {
  51.       _loc2_ = nodeData.byName("labels").byName("result3").getText().split("|");
  52.       _loc3_ = "<FONT COLOR=\"" + strSECTION_COLOR + "\">" + _loc2_[0] + " " + _loc1_ + " " + _loc2_[1] + "</FONT> ";
  53.       output1.htmlText = _loc3_;
  54.    }
  55. };
  56. Selection.setFocus(income_txt);
  57. Selection.setSelection(10,10);
  58.